package com.axjy.base.client;

import com.axjy.base.mapper.ImageMapper;
import com.axjy.comm.client.ImageClient;
import com.axjy.comm.pojo.TpImage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ImageClientImpl implements ImageClient {

    @Resource
    private ImageMapper imageMapper;

    @Override
    public TpImage findByTargetId(Integer targetId, Integer type, Integer category) {
        QueryWrapper<TpImage> queryWrapper= Wrappers.query();
        queryWrapper.eq("target_id",targetId);
        queryWrapper.eq("type",type);
        queryWrapper.eq("category",category);
        List<TpImage> list=imageMapper.selectList(queryWrapper);
        TpImage tpImage=null;
        if(list.size()>0){
            tpImage=list.get(0);
        }
        return tpImage;
    }


}
